import 'package:flutter/material.dart';
import 'package:p_location/common/obj/tag_obj.dart';

import 'common_colors.dart';

class TagView extends StatelessWidget {
  final String tagValue;

  final double marginLeft;
  final double marginTop;
  final double marginRight;
  final double marginBottom;

  final double paddingLeft;
  final double paddingTop;
  final double paddingRight;
  final double paddingBottom;

  final Color strokeColor;
  final Color fillColor;
  final Color textColor;

  final double radius;

  final TagObj tagObj;

  final Function onPress;

  TagView(this.tagValue,
      {this.tagObj,
      this.marginLeft = 0,
      this.marginTop = 0,
      this.marginRight = 0,
      this.marginBottom = 0,
      this.paddingLeft = 0,
      this.paddingTop = 0,
      this.paddingRight = 0,
      this.paddingBottom = 0,
      this.radius = 15,
      this.fillColor = CommonColors.MAIN_BLUE_COLOR,
      this.strokeColor = CommonColors.MAIN_BLUE_COLOR,
      this.textColor = CommonColors.MAIN_WHITE_COLOR,
      this.onPress});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (onPress != null) {
          onPress();
        }
      },
      child: Container(
        margin: EdgeInsets.only(
            left: marginLeft,
            top: marginTop,
            right: marginRight,
            bottom: marginBottom),
        padding: EdgeInsets.only(
            left: paddingLeft,
            top: paddingTop,
            right: paddingRight,
            bottom: paddingBottom),
        decoration: BoxDecoration(
            border: new Border.all(
                color: tagObj?.strokeColor ?? strokeColor, width: 0.5),
            color: tagObj?.fillColor ?? fillColor,
            borderRadius: BorderRadius.circular(radius)),
        child: Text(
          tagObj?.tagValue ?? tagValue,
          style: TextStyle(color: textColor, fontSize: 15),
        ),
      ),
    );
  }
}
